#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int s=0;char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s;
}
bool xx;
const int MAXN=503;
int dis[MAXN][MAXN];
vector<int>now;
struct EDGE{
    int to,pre,v;
    EDGE(int x=0,int y=0,int z=0):to(x),pre(y),v(z){}
}e[MAXN*2];
int u[MAXN],v[MAXN],head[MAXN],tot=0;
void add_e(int u,int v,int col){
    e[++tot]=EDGE(v,head[u],col);
    head[u]=tot;
}
void DFS(int fir,int x,int fr,int maxn){
    dis[fir][x]=maxn;
    // if(fir==x) dis[fir][x]=0;
    for(int i=head[x];i;i=e[i].pre){
        int v=e[i].to;
        if(v==fr) continue;
        DFS(fir,v,x,min(maxn,e[i].v));
    }
}
void calc(int x,int fr){
    now.push_back(x);
    for(int i=head[x];i;i=e[i].pre){
        int v=e[i].to;
        if(v==fr) continue;
        calc(v,x);
    }
}
bool xxx;
signed main(){
    freopen("tatooine.in","r",stdin);
    freopen("tatooine.out","w",stdout);
    // cout<<(&xxx-&xx)/1024.0/1024.0<<endl;
    int N=read();
    for(int i=1;i<N;++i){
        int x=read(),y=read(),z=read();
        u[i]=x,v[i]=y;
        add_e(u[i],v[i],z),add_e(v[i],u[i],z);
    }
    // printf("!!!\n");
    if(N<=500){
        for(int i=1;i<=N;++i) DFS(i,i,0,20);
        for(int k=1,ans=0;k<N;++k,ans=0){
            calc(v[k],u[k]);
            for(int i=0;i<now.size();++i)
                for(int j=i+1;j<now.size();++j) ans+=dis[now[i]][now[j]];
            now.clear();
            calc(u[k],v[k]);
            for(int i=0;i<now.size();++i)
                for(int j=i+1;j<now.size();++j) ans+=dis[now[i]][now[j]];
            printf("%lld\n",ans);
            now.clear();
        }
    }
    return 0;
}